const modulesFiles = import.meta.glob('./modules/**/*.ts', { eager: true })

const pathList = []

for (const path in modulesFiles) {
  pathList.push(path)
}

const api = pathList.reduce((modules: any, modulePath) => {
  const moduleName: any = modulePath.replace(/^\.\/modules\/(.*)\.\w+$/, '$1')
  const value: any = modulesFiles[modulePath]
  modules[moduleName] = value.default
  return modules
}, {})

export default api
